<%template _header%>
<%namespace YouHP.Model%>
<!--TheCurrent start-->
<!--TheCurrent end-->
<!--reg start-->
<%if ErrorCount>0%>
<%template _memerrmsgbox%>
<%else%>
<%if IsPost%>
<div class="layout-cols2">
    <div class="box">
        <div class="caption">
            恭喜，您已经注册成功
        </div>
        <div class="content">
            <div class="navforumtrue">
                {MsgboxText}
                <%if {MsgboxUrl}!=""%>
                <p class="errorback">
                    <a href="{MsgboxUrl}">如果浏览器没有转向, 请点击这里.</a>
                </p>
                <%/if%>
            </div>
        </div>
    </div>
</div>
<%else%>
<script type="text/javascript" language="javascript">
	
	var usernameok = false;
	var emailok = false;
	var pwdok = false;
	var pwd1ok = false;
	var termok = false;
	var diseaseok = false;
	
	function CheckBasicForm()
	{
	   if(usernameok == false) usernameok = checkusername();	
	   if(emailok == false) emailok = checkEmail();
	   if(pwd1ok == false) pwd1ok = checkpwd1();
	   if(pwdok == false) pwdok = checkpwd2();
	   if(termok == false) termok = checkterm();
	   if(diseaseok == false) diseaseok= checkDisease();
	   
	   	   
	   if(usernameok && emailok && pwd1ok && pwdok && termok && diseaseok)
	   {
	        DisableRegisterButton();
	        var f = _$("regform");
	        f.submit();
	   }
	}	
	
	function checkcharactors()
	{
	    var username = document.getElementById("username").value;
	    var reg = /^[0-9a-z_\-\u4e00-\u9fa5]*$/; 
	    return reg.test(username);
	}
	
	function checkspecialname()
	{
	    var username = document.getElementById("username").value;
	    if ((username == "administrator") || (username == "admin")|| (username == "管理员"))
	    {
	        return false;	        
	    }
	    else
	    {
	        return true;
	    }
	}
	
	
	function checkusername()
	{
  		var username = document.getElementById("username").value;
			var unlen = username.replace(/[^\x00-\xff]/g, "**").length;

			if(unlen > 20)
			{
				_$("usernameResult").innerHTML = "<font color='RED'>对不起，您的用户名超过20 个字</font>";
				usernameok = false;
				return false;
			}
			else if(unlen < 3) 
			{
				_$("usernameResult").innerHTML = "<font color='RED'>对不起，您输入的用户名小3个字</font>";
				usernameok = false;
				return false;
			}
			if (!checkcharactors())
			{
				_$("usernameResult").innerHTML = "<font color='RED'>对不起，用户名只能由小写字母、数字、下划线、中文组成</font>";
				usernameok = false;
				return false;
			}
			if (!checkspecialname())
			{
			    _$("usernameResult").innerHTML = "<font color='RED'>对不起，您的用户名是受保留用户名</font>";
				usernameok = false;
				return false;
			}
			
			_$("usernameResult").innerHTML = "正在检查，请稍侯...";
			var aurl = "/tools/userajax.aspx?f=chkusr&usr=" + escape(username);
			var myAjax = new Ajax(aurl, 
			   {
			   	  method: 'get',
			   	  onComplete: function()
			   	  {
			   	  	var result = this.response.text;
			   	  	if (result == "0"){
			   	  	    _$("usernameResult").innerHTML = "√";
			   	  	    usernameok = true;
			   	  	    return true;
			   	    }
			   	    else{
			   	    	  _$("usernameResult").innerHTML = "<font color='#009900'>对不起，您输入的用户名已经存在</font>";
			   	    	  usernameok = false;
			   	    	  return false;
			   	    }
			   	  }
			   }
  	  );
			myAjax.request();
			return false;
	}

	
	function checkEmail()
	{
		var email = document.getElementById("email").value;
		var emailrex = /^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/;
		
		var unlen = email.replace(/[^\x00-\xff]/g, "**").length;
		if(emailrex.test(email)==false)
		{
			_$("emailResult").innerHTML = "<font color='RED'>请输入正确的邮箱</font>";
			emailok = false;
			return;
		}
		_$("emailResult").innerHTML = "正在检查，请稍侯...";
		var aurl = "/tools/userajax.aspx?f=chkemail&email=" + escape(email);
		var myAjax = new Ajax(aurl, 
		   {
		   	  method: 'get',
		   	  onComplete: function()
		   	  {
		   	  	var result = this.response.text;
		   	  	if (result == "0"){
		   	  	    _$("emailResult").innerHTML = "√";
		   	  	    emailok = true;
		   	    }
		   	    else{
		   	    	  _$("emailResult").innerHTML = "<font color='RED'>对不起，您输入的邮箱不可用</font>";
		   	    	  emailok = false;
		   	    }
		   	  }
		   }
        );
		myAjax.request();
		return false;
	}
		
	
	function checkDisease()
	{
	    if (_$("diseaseId").value > 0)
	    {
	        diseaseok = true;
	        _$("diseaseSpan").innerHTML = "√"
	        return true;
	    }
	    else
	    {
	        _$("diseaseSpan").innerHTML = "<font color='RED'>(*)此项有利于寻找和你一样的病友</font>"
	        return false;
	    }
	}
		

  function checkpwd1()
  {
  	  var pwd1 = _$("password").value;
  	  if(pwd1 == "") {
		  	_$("pwdResult").innerHTML = "<font color='RED'>请输入密码</font>";
		  	pwd1ok = false;
		  	return false;
		  }
		  else if(pwd1.length < 6){
		  	_$("pwdResult").innerHTML = "<font color='RED'>不得少于6个字</font>";
		  	pwd1ok = false;
		  	return false;
		  }
		  pwd1ok = true;
		  _$("pwdResult").innerHTML = "√";
		  return true;
  }
		
	function checkpwd2()
	{
		  _$("pwd2Result").innerHTML= "";
		  if(pwd1ok == false) return false;
		  
		  var pwd1 = _$("password").value;
		  var pwd2 = _$("password2").value;
		  document.getElementById("pwd2Result").innerHTML = "√";
		  
		  if(pwd1 != pwd2)
		  {
		  	_$("pwd2Result").innerHTML = "<font color='RED'>两次输入的密码不一致</font>";
		  	pwdok = false;
		  	return false;
		  }
		  
		  pwdok = true;
		  return true;
	}
	
	function checkterm()
	{
	    if (document.getElementById("term").checked == false)
	    {
	        _$("spanTerm").innerHTML = "<font color='RED'>&nbsp;&nbsp;&nbsp;&nbsp;您必须同意优医网的注册条例才能成为优医网的用户</font>";
	        return false;
	    }
	    else
	    {
	        _$("spanTerm").innerHTML = "";
	        return true;
	    }
	}
	function DisableRegisterButton()
	{
	    document.getElementById('btnSubmit').disabled = true;
	}
		
</script>
<div class="layout-cols2">
    <div class="col1">
        <form id="regform" name="regform" method="post" action="">
        <div class="box" id="basicInfo">
            <div class="caption">
                <h3>
                    注册信息</h3>
            </div>
            <div class="content">
                <table class="table-box" width="700px"  border="0" cellpadding="0" cellspacing="0" >
                    <tbody>
                        <tr class="list">
                            <td class="table-box-left" style="width: 140px;">
                                用户名:</td>
                                <td class="table-box-right">
                                    <input name="username" type="text" id="username" maxlength="20" size="30" class="colorblue" style="width:180px;"
                                        onfocus="this.className='colorfocus';" onblur="this.className='colorblue';checkusername('username','usernameResult');" />
                                    <span id="usernameResult" style="color: Green;">(*)必填，3-20个字符(包括小写字母、数字、下划线、中文)</span>
                                </td>
                        </tr>
                        <tr class="list">
                            <td class="table-box-left">
                                密码:</td>
                                <td class="table-box-right">
                                    <input name="password" type="password" id="password" size="30" class="colorblue" maxlength="20" style="width:180px;"
                                        onfocus="this.className='colorfocus';" onblur="this.className='colorblue'; checkpwd1();" />
                                    <span id="pwdResult" style="color: Green;">(*)登陆密码,不得少于6个字</span>
                                </td>
                        </tr>
                        <tr class="list">
                            <td class="table-box-left">
                                <span>确认密码:</span> </td>
                                <td class="table-box-right">
                                    <input name="password2" type="password" id="password2" size="30" class="colorblue" maxlength="20" style="width:180px;"
                                        onfocus="this.className='colorfocus';" onblur="this.className='colorblue'; checkpwd2();" />
                                    <span id="pwd2Result" style="color: Green;">(*)重复输入密码</span>
                                </td>
                        </tr>
                        <tr class="list">
                            <td class="table-box-left">
                                <span>Email:</span> </td>
                                <td class="table-box-right">
                                    <input name="email" type="text" id="email" size="30" class="colorblue" onfocus="this.className='colorfocus';" style="width:180px;"
                                        onblur="this.className='colorblue';checkEmail();" />
                                    <span id="emailResult" style="color: Green;">(*)请正确填写，用来接收验证码</span>
                                </td>
                        </tr>
                        <tr class="list">
                            <td class="table-box-left">
                                <span>您所患疾病:</span>
                            </td>
                            <td class="table-box-right">
                                <input type="hidden" name="dszid" id="dszid" value="" />
                                <select id="diseaseId" name="diseaseId" style="width:180px;">
                                    <option value="0">-请选择-</option>
                                    <option value="1">高血压病</option>
                                    <option value="2">高血脂</option>
                                    <option value="3">克罗恩病</option>
                                    <option value="4">溃疡性结肠炎</option>
                                    <option value="5">糖尿病</option>
                                    <option value="6">特发性血小板减少性紫癜</option>
                                    <option value="7">慢性粒细胞白血病</option>
                                    <option value="8">慢性乙型肝炎/携带者</option>
                                    <option value="9">多发性骨髓瘤</option>
                                    <option value="20">支气管哮喘</option>
                                    <option value="10">其他</option>
                                </select>
                                <span id="diseaseSpan" style="color: Green;">(*)此项有利于寻找和你一样的病友</span>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr class="list">
                            <td class="table-box-left">
                                <span>验证码:</span> </td>
                                <td class="table-box-right">
                                    <input name="ValidationCode" type="text" id="ValidationCode" size="30" class="colorblue" onfocus="this.className='colorfocus';" style="width:180px;"
                                        onblur="this.className='colorblue');" />
                                    <span id="ValidationCodeImg" style="color: Green;"><img src="{vc.url}" width="80px" /></span>
                                </td>
                        </tr>
                        <tr class="list">
                            <td class="table-box-left">
                                <input type="checkbox" name="term" id="term" checked="checked" /><span id="span5"></span>
                            </td>
                            <td class="table-box-right">
                                <%csharp%>TempUrl = "/User/protocolb.aspx";
                                <%/csharp%>
                                <a href="{this.GetUrl(TempUrl)}" target="_blank">我同意注册条例</a><span id="spanTerm"></span>
                            </td>
                        </tr>
                        <tr >
                            <td style="width:140px">
                                
                            </td>
                            <td style="padding-left:20px">
                                <input type="button" id="btnSubmit" class="button" onclick="CheckBasicForm()" value="完成注册" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div align="center">
                    
                </div>
            </div>
        </div>
        </form>
    </div>
    <div class="col2">
        <div class="box">
            <div class="caption">
                加入优医网你可以：</div>
            <div class="content">
                <li>寻找和你一样的病友</li>
                <li>共享你的信息，得到更多帮助</li>
                <li>与相同的病人交流分享</li>
                <li>找到专业的医生</li>
            </div>
        </div>
    </div>
</div>
<%/if%>
<%/if%>
<%template _footer%>
